<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js" type="text/javascript"></script>
        <script src="../js/jquery.ui.datetimepicker.min.js" type="text/javascript"></script>

<?
include ('../config.php');

$id 	= 'promoid';
$vname 	= 'promotions'; 
$cid = $_REQUEST[$id];

$form = new form();
$form->table = "promotions";
$form->action = $config['submit_url'];
$form->include = array("title"=>"title",
                       "Description"=>"description",
                       "start date"=>array('type'=>"calendar","id"=>"start", "v"=>"start","query"=>array("dateFormat"=>"yyyy-mm-dd")),
                       "expiry"=>array('type'=>"calendar","id"=>"end", "v"=>"end","query"=>array("dateFormat"=>"yyyy-mm-dd")),
                       "Shop"=>array('type'=>"select","id"=>"shopid", "v"=>"name","query"=>"select shopid,name from shops"),
		       "discount"=>"discount",
		       "Picture"=>array("type"=>"file","id"=>"pimage","v"=>"pimage","query"=>1),
		       "Thumbnail"=>array("type"=>"file","id"=>"pthumb","v"=>"pthumb","query"=>1),
		       "url"=>"url",
		       "featured"=>array("type"=>"cselect","id"=>"featured","v"=>"featured","query"=>array("0"=>"no","1"=>"yes"))
		       );


if(!$cid){
	$form->title 		= "Add new ".$vname;
	$form->submit 		= "Add ".$vname;
}else{
	$form->title 		= "Edit ".$vname;
	$form->submit 		= "Edit ".$vname;
	$form->index 		= $cid;
	$form->indexname	= $id;
	$form->Addnew		= array('url'=>$_SERVER['PHP_SELF'],'text'=>'Add New '.$vname);
}
$parse = $form->CreateForm();
echo $parse;

$view = new view();
//creating the view
$view->title 						= "Current defined ".$vname;
$view->query 						= "select ".$id.",title,description,discount,start,end from ".$form->table;
$view->properties['headers'] 		= array($vname.' ID'=>"",$vname.' Name'=>"", "desription"=>"","discount"=>"","start"=>"","end"=>"");
$view->properties['cols']			= '5';
$view->properties['editurl']		= $_SERVER['PHP_SELF'];
$view->properties['editparam']  	= array($id=>'##'.$id.'##');
$view->properties['deleteurl']		= $config['submit_url'];
$view->properties['deleteparam']	= array('index'=>'##'.$id.'##','indexname'=>$id,'submit'=>'DELETE','t'=>$form->table);
$parse = $view->CreateView();
echo $parse;
?>
<a href='index.php'>Home</a>